package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizHealthCertificate;
import com.ruoyi.healthCard.service.ITBizHealthCertificateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 健康证Controller
 * 
 * @author ruoyi
 * @date 2025-06-25
 */
@RestController
@RequestMapping("/health/certificate")
public class TBizHealthCertificateController extends BaseController
{
    @Autowired
    private ITBizHealthCertificateService tBizHealthCertificateService;

    /**
     * 查询健康证列表
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizHealthCertificate tBizHealthCertificate)
    {
        startPage();
        List<TBizHealthCertificate> list = tBizHealthCertificateService.selectTBizHealthCertificateList(tBizHealthCertificate);
        return getDataTable(list);
    }

    /**
     * 导出健康证列表
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:export')")
    @Log(title = "健康证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizHealthCertificate tBizHealthCertificate)
    {
        List<TBizHealthCertificate> list = tBizHealthCertificateService.selectTBizHealthCertificateList(tBizHealthCertificate);
        ExcelUtil<TBizHealthCertificate> util = new ExcelUtil<TBizHealthCertificate>(TBizHealthCertificate.class);
        util.exportExcel(response, list, "健康证数据");
    }

    /**
     * 获取健康证详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:query')")
    @GetMapping(value = "/{certId}")
    public AjaxResult getInfo(@PathVariable("certId") Long certId)
    {
        return success(tBizHealthCertificateService.selectTBizHealthCertificateByCertId(certId));
    }

    /**
     * 新增健康证
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:add')")
    @Log(title = "健康证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizHealthCertificate tBizHealthCertificate)
    {
        return toAjax(tBizHealthCertificateService.insertTBizHealthCertificate(tBizHealthCertificate));
    }

    /**
     * 修改健康证
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:edit')")
    @Log(title = "健康证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizHealthCertificate tBizHealthCertificate)
    {
        return toAjax(tBizHealthCertificateService.updateTBizHealthCertificate(tBizHealthCertificate));
    }

    /**
     * 删除健康证
     */
    @PreAuthorize("@ss.hasPermi('health:certificate:remove')")
    @Log(title = "健康证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{certIds}")
    public AjaxResult remove(@PathVariable Long[] certIds)
    {
        return toAjax(tBizHealthCertificateService.deleteTBizHealthCertificateByCertIds(certIds));
    }
}
